package com.lyhengtongwl.zqsnews.adapter;

import android.content.Context;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.lyhengtongwl.zqsnews.R;
import com.lyhengtongwl.zqsnews.entity.WDEntity;
import com.lyhengtongwl.zqsnews.ui.activity.WithDrawNowActivity;

import java.util.ArrayList;
import java.util.List;

public class WithDrawNowAdapter extends BaseQuickAdapter<WDEntity, BaseViewHolder> {
    private List<View> list_ll=new ArrayList<>();
    private List<TextView> list_tv=new ArrayList<>();
    private List<TextView> list_tv1=new ArrayList<>();
    private Context mContext;
    public WithDrawNowAdapter(@Nullable List<WDEntity> data, Context context) {
        super(R.layout.item_money_, data);
        this.mContext=context;
    }
    @Override
    protected void convert(BaseViewHolder helper, WDEntity item) {
        ((TextView)helper.getView(R.id.tv_money)).setText(item.getMoney());
        if (helper.getPosition()==0){
            ((TextView)helper.getView(R.id.tv_money)).setTextColor(mContext.getResources().getColor(R.color.whiteffffff));
            ((TextView)helper.getView(R.id.tv_)).setTextColor(mContext.getResources().getColor(R.color.whiteffffff));
            helper.getView(R.id.ll_).setBackground(mContext.getResources().getDrawable(R.drawable.money_unselected));
        }
        list_ll.add(helper.getView(R.id.ll_));
        list_tv1.add(helper.getView(R.id.tv_));
        list_tv.add(((TextView)helper.getView(R.id.tv_money)));
        helper.getView(R.id.ll_).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                for (int i=0;i< list_ll.size();i++) {
                    if (list_ll.get(i).equals(view)) {
                        WithDrawNowActivity.moneySelected=item.getMoney();
                        ((TextView)list_tv.get(i)).setTextColor(mContext.getResources().getColor(R.color.whiteffffff));
                        ((TextView)list_tv1.get(i)).setTextColor(mContext.getResources().getColor(R.color.whiteffffff));
                        list_ll.get(i).setBackground(mContext.getResources().getDrawable(R.drawable.money_unselected));
                    } else {
                        ((TextView)list_tv.get(i)).setTextColor(mContext.getResources().getColor(R.color.color333));
                        list_ll.get(i).setBackground(mContext.getResources().getDrawable(R.drawable.money_selected));
                        ((TextView)list_tv1.get(i)).setTextColor(mContext.getResources().getColor(R.color.color333));
                    }
                }
            }
        });
    }
}
